-- set_main_target_execute_time
--
local import = import
---@type behavior_ret
local bret = import('bt/bt_plugin/behavior3/behavior_ret')
---@type api
local api = import("api/api")


local M = {
    name = "set_main_target_execute_time",
    type = "Action",
    desc = "设置目标执行时间",
    args = {
        { name = "time", type = "int", desc = "执行时间/秒" },
        { "minRandomTime", "int?", "最小随机时间/秒" },
        { "maxRandomTime", "int?", "最大随机时间/秒" },
        --{
        --    name = "str",
        --    type = "enum",
        --    desc = "目标类型",
        --    options = {
        --        {
        --           name = "测试",
        --           value = "测试",
        --        },
        --    },
        --},
    },
    input = {},
    output = { "执行时间" },
}

function M.run(node, env, value)
    -- node.args.str
    math.randomseed(os.time())
    local time = node.args.time
    local minRandomTime = node.args.minRandomTime
    local maxRandomTime = node.args.maxRandomTime
    if minRandomTime and maxRandomTime then
        time = time + math.random(minRandomTime, maxRandomTime)
    end
    local data = {}
    data.executeTime = time
    return bret.SUCCESS, data
end

return M
